package com.bright.dao;

import com.bright.pojo.Blog;
import com.bright.vo.BlogQuery;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BlogDao extends JpaRepository<Blog,Long>, JpaSpecificationExecutor<Blog> {

    @Query("select b from Blog b where b.ispublished = true")
    List<Blog> findTop(Pageable pageable);


    @Query("select b from Blog b where b.ispublished = true  and (b.title like ?1 or b.content like ?1)")
    List<Blog> findByQuery(String query);
}
